Free to use, free to look at and learn from, free to pinch small chunks of code from for use in your own projects.
However, you may NOT redistribute this widget, or a port or modified version of it, without obtaining permission from the author (via email, hawkman@phantomgorilla.com) and including credit to him in the finished project (a small notice in the widget's javascript/html files is all that's necessary; nothing visible on the widget).
This software is provided as-is, with no guarantee. The author can accept no responsibility for any consequences of its use.
This widget uses Real Player for the audio. Preferences are written upon the selection of an item in a pop-up menu, then this is compared to a list of stations to find the stream url. A function then writes html to the front of the widget to embed the realplayer plugin with the correct url, and changes the image source to reflect which station is playing.
- Credits
Basic Javascript routines taken out of Apple's sample Goodbye World widget. A small section of crash-preventing code is taken from Duncan Ponting's radio widget (http://www.bbc.co.uk/radio/prototypes/listenlive/) at his suggestion - cheers. Also taken from that widget is the idea to crawl the broswer plugins to find RealPlayer. Version string .plist lookup taken from Joshua Emmons' blank foo.wdgt (http://www.skia.net/). Study of his example AppleAnimator use was also extremely helpful. Some button-like routines adapted from Apple's GenericButton class.
Additional skills were obtained by studying Apple's sample files and the Mac OS X bundled widgets, however no actual code was used from these sources other than that mentioned already.
// resets the index global variable (it's not 0, despite our definition
// above, because animateProgressIndicator() has been messing with it), so
// the animation will start from the top next time as expected
index=0;
// if we moused over the radio station image while the indicator was running, we should be showing the "What's On?" link - but we suppressed it while the indicator was running to avoid confusion (see whatsOnOver()). Now, if appropriate, we must run whatsOnOver to fade the link in.
if (shouldShowWhatsOn==true)
{
// calls the fade in
whatsOnOver("");
}
}
// This function does the actual animation, swapping the images in the indicator
// when it's called at intervals by startProgressIndicator(). No need to call
// this directly, it won't work in the same way.
function animateProgressIndicator()
{
// change the source of the indicator image to another of those held in the
// progressIndicatorImages array (determined by the current value of index)